function BXBlockEditorPreview(t){this.init(t)}BXBlockEditorPreview.prototype.init=function(t){this.url=t.url;this.site=t.site;this.previewContext=BX.findChildByClassName(t.context,"bx-block-editor-preview-container",true);this.devicesContext=BX.findChildByClassName(this.previewContext,"devices",true);this.iframePreview=BX.findChildByClassName(this.previewContext,"preview-iframe",true);this.shadowNode=BX.findChild(this.previewContext,{className:"shadow"},true);var e=this;this.deviceList=BX.findChildrenByClassName(this.devicesContext,"device");for(var i in this.deviceList){var n=this.deviceList[i];BX.bind(n,"click",function(){e.changeDevice(this)})}this.changeDevice();var r=function(){BX.loadCSS("/bitrix/js/fileman/block_editor/preview.css?r="+Math.random(),this.contentDocument,this.contentWindow);BX.removeClass(e.shadowNode,"active")};BX.ready(function(){BX.bind(e.iframePreview,"load",r)})};BXBlockEditorPreview.prototype.changeDevice=function(t){if(!t){t=this.deviceList[0]}var e=t.getAttribute("data-bx-preview-device-width");var i=t.getAttribute("data-bx-preview-device-height");var n=t.getAttribute("data-bx-preview-device-class");var r=[];for(var a in this.deviceList){var o=this.deviceList[a];if(!o){break}if(o!==t){BX.removeClass(o,"active")}r.push(o.getAttribute("data-bx-preview-device-class"))}BX.addClass(t,"active");var s=BX.findChildByClassName(this.previewContext,"iframe-wrapper",true);if(s){BX.removeClass(s,r.join(" "));BX.addClass(s,n)}this.iframePreview.style.width=e+"px";this.iframePreview.style.height=i+"px"};BXBlockEditorPreview.prototype.show=function(t){t=t||{};BX.addClass(this.shadowNode,"active");BX.removeClass(this.shadowNode,"access-denied");this.previewContext.style.display="block";var e=this.iframePreview.contentDocument;e.body.innerHTML='<div style="display: none;">'+'<form method="post">'+'<textarea name="content"></textarea>'+'<input type="hidden" name="sessid" value="'+BX.bitrix_sessid()+'">'+"</form>"+"</div>";var i=e.body.querySelector("textarea");i.textContent=t.content;var n=e.body.querySelector("form");n.action=this.url;BX.submit(n)};BXBlockEditorPreview.prototype.hide=function(){this.previewContext.style.display="none"};function BXBlockEditorDragDrop(t){this.CONST_ATTR_BLOCK_TYPE="data-bx-block-editor-block-type";this.CONST_ATTR_BLOCK_STATUS="data-bx-block-editor-block-status";this.init(t)}BXBlockEditorDragDrop.prototype={addItem:function(t){this.dragdrop.addCatcher(t);this.dragdrop.addDragItem([t])},removeItem:function(t){this.dragdrop.removeCatcher(t)},init:function(t){this.dragdrop=BX.DragDrop.create({dragItemClassName:"bx-block-editor-i-block-list-item",dropZoneList:[],dragStart:BX.delegate(function(t,e,i){this.lastDragObject=null;this.dragEnterCounter=0;for(var n in this.dragdrop.dropZoneNodeList){BX.addClass(this.dragdrop.dropZoneNodeList[n],"bx-dd-start")}},this),dragDrop:BX.delegate(function(t,e,i){BX.onCustomEvent(this,"onZoneLeave",[t]);var n=BX.pos(t);var r=i.offsetY<n.height/2;var a=e.getAttribute(this.CONST_ATTR_BLOCK_STATUS);if(a=="blank"){var o=e.getAttribute(this.CONST_ATTR_BLOCK_TYPE);BX.onCustomEvent(this,"onItemAdd",[o,t,r])}else{BX.onCustomEvent(this,"onItemMove",[e,t,r])}},this),dragOver:BX.delegate(function(t,e,i){var n=BX.findChildByClassName(t,"bx-block-inside",true);n=n||t;var r=BX.pos(n);if(i.offsetY<r.height/2){BX.onCustomEvent(this,"onZoneEnter",[t,true])}else{BX.onCustomEvent(this,"onZoneEnter",[t,false])}},this),dragEnter:BX.delegate(function(t,e,i){if(t==i.target){BX.onCustomEvent(this,"onZoneEnter",[t,true]);i.preventDefault()}},this),dragLeave:BX.delegate(function(t,e,i){if(t==i.target){BX.onCustomEvent(this,"onZoneLeave",[t]);this.dragEnterCounter=0}},this),dragEnd:BX.delegate(function(t,e,i){BX.onCustomEvent(this,"onZoneLeave",[t]);for(var n in this.dragdrop.dropZoneNodeList){BX.removeClass(this.dragdrop.dropZoneNodeList[n],"bx-dd-start")}},this)})}};function BXBlockEditorDialogFileInput(t){this.isMultiImage=true;this.caller=t.caller;this.context=this.caller.context;this.id=t.id;this.fileInput=BX.UI.FileInput.getInstance("bx_file_"+this.id.toLowerCase());this.fileList=[];BX.addCustomEvent(this.caller,"onLinkControl-src",BX.delegate(this.onLink,this));BX.addCustomEvent(this.caller,"onSave",BX.delegate(this.onSave,this));BX.addCustomEvent(this.caller,"loadSetting-src",BX.delegate(this.onLoadSetting,this))}BXBlockEditorDialogFileInput.prototype={getImages:function(){var t=this.fileInput.agent.getItems();t.reset();var e,i=[];while((e=t.getNext())&&e){i.push(e.id)}return i.map(function(t){var e=this.fileList.filter(function(e){return e.id==t&&e.url});if(e.length>0){return e[e.length-1].url}else{return null}},this)},setImages:function(t){this.fileInput.deleteFiles();this.fileDialogFiles={};var e=this.fileInput.uploadParams["frameFiles"];this.fileInput.uploadParams["frameFiles"]="N";for(var i in t){var n=t[i];var r=n.split("/");var a=r.pop();var o=r.join("/");this.fileInput.handlerFileDialog(a,o)}this.fileInput.uploadParams["frameFiles"]=e},onAgentChange:function(t){t.value=this.getImages().join(",");BX.onCustomEvent(t,"onSettingChangeValue")},onLoadSetting:function(t){this.isMultiImage=!!t.params.multi},onLink:function(t){var e=t.ctrl;var i=t.code;var n=e;BX.addCustomEvent(n,"onSettingLoadValue",BX.delegate(function(){var t=[];var e=n.value.split(",");for(var i in e){var r=e[i].split("?");t.push(r[0])}this.setImages(t)},this));BX.addCustomEvent(this.fileInput.agent,"onAttachFiles",BX.delegate(function(){if(!this.isMultiImage){this.semaphoreOnQueueIsChanged=true;this.fileInput.deleteFiles()}},this));BX.addCustomEvent(this.fileInput.agent,"onQueueIsChanged",BX.delegate(function(){if(!this.semaphoreOnQueueIsChanged){this.onAgentChange(n)}this.semaphoreOnQueueIsChanged=false},this));this.onFileIsCreated=function(t,e){this.semaphoreOnQueueIsChanged=true;if(e.file["tmp_url"]){this.fileList.push({id:t,url:e.file["tmp_url"],path:e.file["tmp_url"]})}if(BX.util.in_array(e["type"],["image/filedialog","image/medialib"])){BX.addCustomEvent(this.fileInput.agent,"onFileIsInited",BX.delegate(function(){this.onAgentChange(n)},this))}BX.addCustomEvent(e,"onUploadDone",BX.delegate(function(t,e){var i=e.file.files.default.url;i+=(i.indexOf("?")>0?"&":"?")+"r="+Math.random();this.fileList.push({id:e.file.id,url:i,path:e.file.files.default.path});this.onAgentChange(n)},this))};BX.addCustomEvent(this.fileInput.agent,"onFileIsCreated",BX.delegate(this.onFileIsCreated,this));t.bind=false},onSave:function(){var t=false;var e=BX.findChildByClassName(this.context,"adm-fileinput-area-container",true);var i=e.querySelectorAll('input[name^="NEW_FILE_EDITOR"]');var n={};for(var r in i){if(i[r]&&i[r].getAttribute){var a=i[r].getAttribute("name");var o=i[r].value;n[i[r].getAttribute("name")]=o;if(a.indexOf("tmp_name")>-1){var s=this.fileList.filter(function(t){return o==t.path&&t.saved}).length>0;if(!s){t=true}}}}if(!t){return}BX.ajax({url:this.caller.saveFileUrl,method:"POST",data:n,dataType:"json",async:false,onsuccess:BX.delegate(this.onImagesSaved,this)})},onImagesSaved:function(t){for(var e in this.caller.tabList){var i=this.caller.tabList[e].items["src"];if(!i){continue}if(!i.ctrl.value){continue}t.data.list.forEach(function(t){var e=this.fileList.filter(function(e){if(!e.path&&e.url){return e.url.indexOf(t.tmp)>=0}return t.tmp==e.path});e.forEach(function(e){i.ctrl.value=i.ctrl.value.replace(e.url,t.path);e.saved=true})},this);BX.onCustomEvent(i.ctrl,"onSettingChangeValue")}if(t.error){alert(t.errorText)}}};function BXBlockEditorEditDialogColumn(t){this.attributeColumnNum="data-bx-editor-column-number";this.attributeColumnValue="data-bx-editor-column-value";this.attributeColumnCount="data-bx-editor-column-count";this.caller=t.caller;BX.addCustomEvent(this.caller,"onLinkControl",BX.delegate(this.onLinkControl,this));BX.addCustomEvent(this.caller,"loadSetting",BX.delegate(this.onLoadSetting,this))}BXBlockEditorEditDialogColumn.prototype={getColumnList:function(t){return BX.findChildren(t,{attribute:this.attributeColumnNum},true)},bindOnSwitch:function(t,e){BX.bind(e,"click",BX.delegate(function(){var i=e.getAttribute(this.attributeColumnNum);t.setAttribute(this.attributeColumnValue,i);var n=this.caller.getCtrlContainer(t);var r=this.getColumnList(n.container);for(var a in r){BX.removeClass(r[a],"active")}BX.addClass(e,"active");var o=this.caller.caller.getCurrentEditingBlock().getEditValue(n.code,i);this.caller.setCtrlValue(t,o)},this))},onSettingDependenceChange:function(t,e){var i=e.container.container;var n=t.value?t.value:1;n=parseInt(n);if(n<2){n=0}var r=this.getColumnList(i);var a=0;for(var o in r){a++;var s=a<=n?"":"none";var l=r[o];l.style.display=s}this.switchDefaultColumn(i)},hideAllColumns:function(t){var e=this.getColumnList(t);for(var i in e){if(!e.hasOwnProperty(i)){continue}var n=e[i];n.style.display="none"}},switchDefaultColumn:function(t){var e=this.getColumnList(t);if(e.length>0){BX.fireEvent(e[0],"click")}},onLoadSetting:function(t){this.hideAllColumns(t.container.container);this.switchDefaultColumn(t.container.container)},onLinkControl:function(t){var e=this.getColumnList(t.container);for(var i in e){this.bindOnSwitch(t.ctrl,e[i])}if(e.length>0){BX.addCustomEvent(this.caller,"onSettingDependenceChange-"+t.code,BX.delegate(this.onSettingDependenceChange,this))}}};function BXBlockEditorSocial(t){this.caller=t.caller;BX.addCustomEvent(this.caller,"onLinkControl-social_content",BX.delegate(this.onLinkControl,this));BX.addCustomEvent(this.caller,"loadSetting-social_content",BX.delegate(this.onLoadSetting,this))}BXBlockEditorSocial.prototype={onLoadSetting:function(t){this.inputControl=t.ctrl;BX.cleanNode(this.itemContainer);var e=JSON.parse(t.value);for(var i in e){var n=e[i];this.addItem(n.href,n.name)}},fireChange:function(){this.inputControl.value=JSON.stringify(this.getValue());BX.onCustomEvent(this.inputControl,"onSettingChangeValue")},getValue:function(){var t=[];var e=this.getItemList();for(var i in e){var n=e[i];var r=this.getItemControl(n,"href");var a=this.getItemControl(n,"name");t.push({name:a.value,href:r.value})}return t},getItemList:function(){return BX.findChildren(this.itemContainer,{attribute:"data-bx-block-editor-social-item"},true)},getItem:function(t){return BX.findParent(t,{attribute:"data-bx-block-editor-social-item"})},getItemControl:function(t,e){return BX.findChildByClassName(t,e,true)},removeItem:function(t){BX.remove(this.getItem(t))},changePreset:function(t){var e=this.getItem(t);var i=this.getItemControl(e,"href");var n=this.getItemControl(e,"name");i.value=t.value;n.value=t.options[t.selectedIndex].text},addItem:function(t,e){var i=this.templateItem.innerHTML;i=i.replace("#href#",BX.util.htmlspecialchars(t));i=i.replace("#name#",BX.util.htmlspecialchars(e));var n=BX.create("div",{attrs:{"data-bx-block-editor-social-item":"item"},html:i});var r=this.getItemControl(n,"delete");if(this.getValue().length==0){r.style.display="none"}var a=this.getItemControl(n,"preset");var o=this.getItemControl(n,"name");var s=this.getItemControl(n,"href");var l=this;BX.bind(o,"bxchange",function(){l.fireChange()});BX.bind(s,"bxchange",function(){l.fireChange()});BX.bind(r,"click",function(){l.removeItem(this);l.fireChange()});BX.bind(a,"change",function(){l.changePreset(this);l.fireChange()});this.itemContainer.appendChild(n);this.fireChange()},onLinkControl:function(t){this.container=t.container;this.templateItem=BX("template-social-item");this.itemContainer=BX.findChildByClassName(this.container,"container",true);var e=BX.findChildByClassName(this.container,"add",true);var i=this;BX.bind(e,"click",function(){i.addItem("","")})}};function BXBlockEditorEditDialog(t){this.changeList=[];this.tabList={};this.ctrlList={};this.itemFilter=[];this.itemPrevValues=[];this.htmlEditorParsedPhp=[];this.doNotProcessChanging=false;this.init(t)}BXBlockEditorEditDialog.prototype={getPlaceCaption:function(t){var e=BX.message("BLOCK_EDITOR_PLACE_CAPTION_"+t.toUpperCase());if(!e){e=t}return e},init:function(t){this.attributePlaceName="data-bx-place-name";this.attributeTab="data-bx-block-editor-settings-tab";this.attributeLink="data-bx-editor-tool";this.attributeCtrl="data-bx-editor-tool-input";this.caller=t.caller;this.callerContext=t.context;this.saveFileUrl=t.saveFileUrl;this.context=this.callerContext.querySelector(".edit-panel");this.contextTools=this.context.querySelector(".block-edit-cont");this.contextVisual=this.context.querySelector(".visual-part");this.contextPanel=this.context.querySelector(".dialog-part");this.contextPlaceList=this.contextPanel.querySelector(".edit-panel-tabs-style");this.buttonSave=BX.findChild(this.contextTools,{className:"bx-editor-block-tools-close"},true);this.buttonClose=BX.findChild(this.contextTools,{className:"bx-editor-block-tools-cancel"},true);BX.bind(this.buttonSave,"click",BX.delegate(this.save,this));BX.bind(this.buttonClose,"click",BX.delegate(this.cancel,this));this.helper=new BXBlockEditorHelper;this.fileInput=new BXBlockEditorDialogFileInput({caller:this,id:"BX_BLOCK_EDITOR_SRC_"+this.caller.id});this.column=new BXBlockEditorEditDialogColumn({caller:this});this.social=new BXBlockEditorSocial({caller:this});this.initHtmlEditor();this.initColorPicker();this.initBorderControl();this.initTabs();this.initPlaceList();this.initTools()},initPlaceList:function(){BX.addCustomEvent(this.caller,"onLoadAfter",BX.delegate(this.onEditorLoadAfter,this))},onEditorLoadAfter:function(t,e,i){var n=BX.findChild(this.contextPlaceList,{attribute:this.attributePlaceName},true);if(!n){return}BX.cleanNode(n);var r=function(){return function(t,e){var i=this;BX.bind(t,"click",function(){BX.onCustomEvent(i,"onPlaceEdit",[e])});BX.bind(t,"mouseenter",function(){BX.onCustomEvent(i,"onPlaceHover",[e,true])});BX.bind(t,"mouseleave",function(){BX.onCustomEvent(i,"onPlaceHover",[e,false])})}}();var a=i.findStylistPlaces();for(var o in a){var s=this.getPlaceCaption(o);var l=BX.create("li",{text:s,attrs:{title:s}});n.appendChild(l);r.apply(this,[l,o])}},initTabs:function(){var t=BX.findChildren(BX.findChildByClassName(this.contextTools,"block-edit-tabs"),{attribute:this.attributeTab},true);for(var e in t){var i=t[e];var n=i.getAttribute(this.attributeTab);this.tabList[n]={node:i,items:{}};BX.bind(i,"click",BX.delegate(this.onTabClick,this))}},initTools:function(){var t=BX.findChildren(this.context,{attribute:this.attributeLink},true);for(var e in t){var i=t[e];var n=i.getAttribute(this.attributeLink);var r=n.split(":");var a=BX.findChild(i,{attribute:this.attributeCtrl},true);if(!a){continue}this.tabList[r[0]]["items"][r[1]]={node:i,ctrl:a};var o={code:r[1],group:r[0],ctrl:a,container:i,bind:true};BX.onCustomEvent(this,"onLinkControl",[o]);BX.onCustomEvent(this,"onLinkControl-"+o.code,[o]);this.ctrlList[o.code]=o.ctrl;this.linkControl(o.ctrl,o.code,o.bind)}},initHtmlEditor:function(){this.htmlEditor=BXHtmlEditor.Get("BX_BLOCK_EDITOR_CONTENT_"+this.caller.id);var t=400;this.htmlEditor.MIN_WIDTH=t;this.htmlEditor.ResizeSceleton();this.htmlEditor.AutoResizeSceleton();BX.addCustomEvent(this,"onLinkControl-content",BX.delegate(function(t){var e=t.ctrl;var i=t.code;var n=e;BX.addCustomEvent(this.htmlEditor,"OnContentChanged",BX.delegate(function(t){n.value=this.phpParser.replacePhpByLayout(t);BX.onCustomEvent(n,"onSettingChangeValue")},this));BX.addCustomEvent(n,"onSettingLoadValue",BX.delegate(function(){var t=this.phpParser.replaceLayoutByPhp(n.value);this.htmlEditor.SetContent(t,true)},this));t.bind=false},this))},initColorPicker:function(){this.picker=new BX.ColorPicker({popupOptions:{offsetLeft:15,offsetTop:5}});BX.addCustomEvent(this,"onHide",this.picker.close.bind(this.picker));var t=function(t,e){var i=t.value;if(!i){return}e.style.background=t.value};var e=function(t,e){if(!this.picker){return}this.picker.close();this.picker.open({defaultColor:"",allowCustomColor:true,bindElement:e,onColorSelected:function(e){t.value=e;BX.fireEvent(t,"change")}})};var i=this.context.querySelectorAll(".bx-editor-color-picker");i=BX.convert.nodeListToArray(i);i.forEach(function(i){var n=BX.nextSibling(i);var r=BX.nextSibling(n);var a=e.bind(this,i,n);var o=t.bind(this,i,n);BX.bind(n,"click",a);BX.bind(r,"click",a);BX.addCustomEvent(i,"onSettingLoadValue",o);BX.bind(i,"bxchange",o)},this)},initBorderControl:function(){var t=BX("block_editor_style_border");var e=BX("block_editor_style_border_style");var i=BX("block_editor_style_border_width");var n=BX("block_editor_style_border_color");var r=function(){var r="";if(e.value){if(!i.value){i.value="2px"}if(!n.value){n.value="#000000"}r=i.value+" "+e.value+" "+n.value}t.value=r;BX.fireEvent(t,"change")};BX.addCustomEvent(t,"onSettingLoadValue",BX.delegate(function(){if(t.value){var r=t.value.split(" ");for(var a=3;a<r.length;a++){r[2]=r[2]+" "+r[a]}i.value=r[0];e.value=r[1];n.value=this.helper.colorRgbToHex(r[2]);BX.fireEvent(n,"change")}},this));BX.bind(e,"bxchange",r);BX.bind(i,"bxchange",r);BX.bind(n,"bxchange",r)},getCtrlContainer:function(t){var e=BX.findParent(t,{attribute:this.attributeLink});var i=e.getAttribute(this.attributeLink);var n=i.split(":");return{container:e,tab:n[0],code:n[1]}},setCtrlValue:function(t,e){t.value=e;if(typeof t.oldValue==="undefined"){t.oldValue=t.value}BX.onCustomEvent(t,"onSettingLoadValue")},getCtrlValue:function(t){return t.value},onControlChangeValue:function(t){if(!this.caller.getCurrentEditingBlock()){return}var e=this.getCtrlContainer(t);var i=e.code;var n=t.value;var r=t.getAttribute(this.column.attributeColumnValue);BX.onCustomEvent(this,"controlChangeValue",[i,n,r]);if(!BX.util.in_array(t,this.changeList)){this.changeList.push(t)}this.fireDependenceChange(i)},linkControl:function(t,e,i){var n=this;BX.addCustomEvent(t,"onSettingChangeValue",function(){if(!n.doNotProcessChanging){n.onControlChangeValue(this)}});if(i){var r=function(){BX.onCustomEvent(this,"onSettingChangeValue")};BX.bind(t,"change",r);if(t.nodeName=="INPUT"||t.nodeName=="TEXTAREA"){BX.bind(t,"input",r)}}},onTabClick:function(t){t=t||window.event;var e=t.target;var i=e.getAttribute(this.attributeTab);this.showTab(i)},fireDependenceChange:function(t){if(!this.itemDependence||!this.itemDependence[t]||this.itemDependence[t].length==0){return}var e=this.ctrlList[t];if(!e)return;var i=this.getCtrlContainer(e);var n={code:t,value:this.getCtrlValue(e),ctrl:e,container:i};for(var r in this.itemDependence[t]){var a=this.itemDependence[t][r];var o=this.ctrlList[a];if(!o)continue;var s=this.getCtrlContainer(o);var l={code:a,value:this.getCtrlValue(o),ctrl:o,container:s};BX.onCustomEvent(this,"onSettingDependenceChange-"+a,[n,l])}},load:function(t){this.doNotProcessChanging=true;this.itemFilter=[];this.itemDependence={};this.itemPrevValues=[];for(var e in t){var i=t[e].code;var n=t[e].value;var r=t[e].params;var a=t[e].dependence;var o=this.ctrlList[i];if(!o)continue;var s=this.getCtrlContainer(o);this.itemFilter.push(i);this.itemDependence[i]=a;var l={code:i,value:n,params:r,ctrl:o,container:s,dependence:a};BX.onCustomEvent(this,"loadSetting",[l]);BX.onCustomEvent(this,"loadSetting-"+i,[l]);o.value=n;o.oldValue=o.value;BX.onCustomEvent(o,"onSettingLoadValue");this.fireDependenceChange(i)}BX.onCustomEvent(this,"loadSettings",[t]);this.doNotProcessChanging=false;for(var c in this.tabList){var h=false;for(var u in this.tabList[c].items){if(BX.util.in_array(u,this.itemFilter)){h=true;break}}if(h){this.tabList[c].node.style.display=""}else{this.tabList[c].node.style.display="none"}}this.showTab()},save:function(t){var e=BX.showWait(this.buttonSave);var i=this.changeList.length>0;BX.onCustomEvent(this,"onSave",[i]);BX.closeWait(this.buttonSave);this.hide(t)},cancel:function(t){for(var e in this.changeList){var i=this.changeList[e];i.value=i.oldValue;this.onControlChangeValue(i)}var n=false;BX.onCustomEvent(this,"onCancel",[n]);this.hide(t)},show:function(){BX.onCustomEvent(this,"onShow");var t=this.contextTools;var e=this.contextVisual;var i=this.context;t.style.display="block";if(t.offsetWidth+e.offsetWidth>i.offsetWidth){e.style.width=i.offsetWidth-t.offsetWidth+"px"}t.style.right="0";t.style.visibility="visible"},hide:function(t){BX.onCustomEvent(this,"onHide");var e=this.contextTools;var i=this.contextVisual;if(this.contextTools.style.display=="none"){if(t&&BX.type.isFunction(t)){t.apply()}}else{if(t&&BX.type.isFunction(t)){e.style.right="-10%";setTimeout(t,200)}else{e.style.right="-100%";e.style.display="block";e.style.visibility="hidden";i.style.width="100%"}}},hideTab:function(){for(var t in this.tabList){for(var e in this.tabList[t]["items"]){this.tabList[t]["items"][e].node.style.display="none"}}},showTab:function(t){this.hideTab();for(var e in this.tabList){BX.removeClass(this.tabList[e]["node"],"active")}if(!t){var i=[];for(var n in this.tabList){if(this.tabList[n].node.style.display!="none"){i.push(n)}}for(var r in this.tabList){if(BX.util.in_array(r,i)){t=r;break}}}var a=BX.findChildByClassName(this.context,"block-edit-form-empty",true);if(!t){BX.addClass(a,"active");return}else{BX.removeClass(a,"active")}BX.addClass(this.tabList[t]["node"],"active");for(var o in this.tabList[t]["items"]){if(this.itemFilter.length>0&&!BX.util.in_array(o,this.itemFilter)){continue}this.tabList[t]["items"][o].node.style.display="block"}}};function BXBlockEditorSliceContent(t){this.sectionId="BX_BLOCK_EDITOR_EDITABLE_SECTION";this.textarea=t.textarea;this.caller=t.caller}BXBlockEditorSliceContent.prototype.getSectionHtml=function(t,e){var i=[this.sectionId].concat(t).join("/")+"/";return"\x3c!--START %TAG%--\x3e\n%CONTENT%\n\x3c!--END %TAG%--\x3e\n".replace("%TAG%",i).replace("%TAG%",i).replace("%CONTENT%",e)};BXBlockEditorSliceContent.prototype.getSlices=function(){var t={};var e=this.textarea.value;var i="\x3c!--START "+this.sectionId+"/([\\w]+?)/([\\w]+?)/--\x3e"+"([\\s\\S,\\n]*?)"+"\x3c!--END "+this.sectionId+"[/\\w]+?--\x3e";var n=new RegExp(i,"g");var r;while(r=n.exec(e)){var a=r[1].trim();var o=r[2].trim();var s=r[3].trim();if(!BX.type.isArray(t[a])){t[a]=[]}t[a].push({section:a,item:o,value:s})}return t};BXBlockEditorSliceContent.prototype.getHtml=function(t){var e="";this.caller.helper.each(t,function(t){this.caller.helper.each(t,function(t){e=e+this.getSectionHtml([t.section,t.item],t.value)},this)},this);return e};function BXBlockEditorCssParser(){this.patternRule="([\\s\\S]*?){([\\s\\S]*?)}";this.patternDeclaration="([\\s\\S]+?):([\\s\\S]+?);";this.patternStyleSheet="<style[\\s\\S]*?>([\\s\\S]*?)</style>";this.patternComments="(\\/\\*[\\s\\S]*?\\*\\/)";this.patternMedia="(@media[\\s\\S]*?){([}\\s\\S]*?)}[\\r\\n ]*?}"}BXBlockEditorCssParser.prototype.parseRules=function(t){var e={};var i,n,r;var a=new RegExp(this.patternRule,"g");while(i=a.exec(t)){n=i[1].trim();r=i[2].trim();if(!e[n]){e[n]={}}e[n]=BX.merge(e[n],this.parseDeclaration(r))}return e};BXBlockEditorCssParser.prototype.parseDeclaration=function(t){var e={};var i=new RegExp(this.patternDeclaration,"g");var n,r,a;while(n=i.exec(t)){r=n[1].trim();a=n[2].trim();e[r]=a}return e};BXBlockEditorCssParser.prototype.mergeStyles=function(t,e){for(var i in e){if(!e[i]){continue}if(!t[i]){t[i]={}}t[i]=BX.merge(t[i],e[i])}return t};BXBlockEditorCssParser.prototype.diffStylesAll=function(t,e){var i={};var n;for(var r in e){if(!e[r]){continue}if(!t[r]){i[r]=e[r]}else{n=this.diffStyles(t[r],e[r]);if(BX.util.object_keys(n).length>0){i[r]=n}}}if(BX.util.object_keys(i).length>0){return i}else{return null}};BXBlockEditorCssParser.prototype.diffStyles=function(t,e){var i={};for(var n in e){if(!e[n]){continue}var r=e[n];if(!t[n]&&BX.util.object_keys(r).length>0){i[n]=r}else if(!BX.type.isString(r)){for(var a in r){if(!r[a]){continue}if(!t[n][a]||t[n][a]!=r[a]){if(!i[n]){i[n]={}}i[n][a]=r[a]}}}}return i};BXBlockEditorCssParser.prototype.parseTag=function(t){var e="";var i=new RegExp(this.patternStyleSheet,"gi");var n=new RegExp(this.patternComments,"g");if(!(matches=i.exec(t))){matches=[t,t]}do{e+=matches[1].trim()+"\n"}while(matches=i.exec(t));e=e.replace(n,"");return e};BXBlockEditorCssParser.prototype.parse=function(t){t=t||"";var e={"":{}};var i;var n=new RegExp(this.patternMedia,"gi");var r=this.parseTag(t);r=r.trim();while(i=n.exec(r)){var a=i[1].trim();var o=i[2].trim()+"}";if(!e[a]){e[a]={}}e[a]=this.mergeStyles(e[a],this.parseRules(o));r=r.replace(i[0],"")}e[""]=this.mergeStyles(e[""],this.parseRules(r));return e};BXBlockEditorCssParser.prototype.getCssString=function(t){var e="",i,n,r,a;for(i in t){if(!t[i])break;if(i){e+=i+"{\n"}for(n in t[i]){if(!n||!t[i][n])break;e+=n+"{\n";for(r in t[i][n]){if(!r||!t[i][n][r])break;a=t[i][n][r];e+=r+": "+a+";\n"}e+="}\n"}if(i){e+="}\n"}}return e};BXBlockEditorCssParser.prototype.setStyle=function(t,e,i,n){var r,a;e=e||"";i=i.trim();r=this.parse(t);if(!r[e]){a={}}else{a=r[e]}for(var o in n){var s=n[o];if(s){if(!a[i]){a[i]={}}a[i][o]=s}else if(a[i]){delete a[i][o]}}r[e]=a;return this.getCssString(r)};BXBlockEditorCssParser.prototype.getStyle=function(t,e,i,n){var r={},a,o;e=e||"";i=i.trim();a=this.parse(t);if(!a[e]){o={}}else{o=a[e]}for(var s in n){var l=n[s];if(!o[i]||!o[i][l]){r[l]=null}else{r[l]=o[i][l]}}return r};function BXBlockEditorStatusManager(t){this.caller=t.caller;BX.addCustomEvent(this.caller,"onPlaceInitBlocksContent",BX.delegate(this.onPlaceInitBlocksContent,this.caller));BX.addCustomEvent(this.caller,"onBlockCreateAfter",BX.delegate(this.setBlockStatusContent,this.caller));BX.addCustomEvent(this.caller,"onBlockMoveAfter",BX.delegate(this.setBlockStatusContent,this.caller));BX.addCustomEvent(this.caller,"onBlockRemoveAfter",BX.delegate(this.onBlockRemoveAfter,this));BX.addCustomEvent(this.caller,"onBlockClone",BX.delegate(this.setBlockStatusContent,this.caller));BX.addCustomEvent(this.caller,"onBlockEditEnd",BX.delegate(this.onBlockEditEnd,this.caller))}BXBlockEditorStatusManager.prototype.getPlaceNameList=function(t){var e=[];this.caller.helper.each(t,function(t){if(!t.getAttribute){return}var i=t.getAttribute(this.CONST_ATTR_BLOCK_STATUS);var n=t.parentNode.getAttribute(this.CONST_ATTR_PLACE);if(i!="loaded"||n=="body"){e.push(n)}},this.caller);return e};BXBlockEditorStatusManager.prototype.setBlockStatusContent=function(t){t.node.setAttribute(this.CONST_ATTR_BLOCK_STATUS,"content")};BXBlockEditorStatusManager.prototype.onBlockRemoveAfter=function(t){this.onPlaceInitBlocksContent.call(this.caller,t,true)};BXBlockEditorStatusManager.prototype.onBlockEditEnd=function(t,e){if(e){t.node.setAttribute(this.CONST_ATTR_BLOCK_STATUS,"content")}};BXBlockEditorStatusManager.prototype.onPlaceInitBlocksContent=function(t,e){var i="loaded";if(e){i="content"}var n=BX.findChildren(t,{attribute:this.CONST_ATTR_BLOCK},true);for(var r in n){var a=n[r];a.setAttribute(this.CONST_ATTR_BLOCK_STATUS,i)}};BX.addCustomEvent("GetControlsMap",function(t){if(this.id.indexOf("BX_BLOCK_EDITOR_CONTENT_")!==0){return}var e=["ChangeView","placeholder_selector","StyleSelector","FontSelector","FontSize","RemoveFormat","Bold","AlignList","Color","Fullscreen","More"];for(var i in t){var n=t[i];if(n){if(n.separator){n.hidden=true}else if(!BX.util.in_array(n.id,e)){n.compact=false}else{n.compact=true}}}});(function(t){function e(t){this.textarea=t.textarea;this.caller=t.caller;var e=this.getRaw();this.converter=new n}e.prototype.getRaw=function(){return this.textarea.value};e.prototype.setRaw=function(t){this.textarea.value=t};e.prototype.getString=function(t){return this.converter.toString(t)};e.prototype.getList=function(){var t=this.getRaw();if(t){return this.converter.toArray(t)}return[]};e.prototype.getStyles=function(){return this.getList().filter(function(t){return t&&t.type==="STYLES"})};e.prototype.getBlocks=function(){return this.getList().filter(function(t){return t&&t.type==="BLOCKS"})};function i(){}i.isValid=function(t){try{var e=JSON.parse(t);return BX.type.isPlainObject(e)||BX.type.isArray(e)}catch(t){return false}};i.prototype.toArray=function(t){try{return JSON.parse(t)}catch(t){return[]}};i.prototype.toString=function(t){t=t.map(function(t){var e={type:t.type,place:t.place,value:t.value};if(t.block){e.block=t.block}return e});try{return JSON.stringify(t)}catch(t){return""}};function n(){this.sectionId="BX_BLOCK_EDITOR_EDITABLE_SECTION"}n.prototype.toArray=function(t){var e=[];var i="\x3c!--START "+this.sectionId+"/([\\w]+?)/([\\w]*?)/--\x3e"+"([\\s\\S,\\n]*?)"+"\x3c!--END "+this.sectionId+"[/\\w]+?--\x3e";var n=new RegExp(i,"g");var r;while(r=n.exec(t)){var a=r[1].trim();var o=r[2].trim();var s=r[3].trim();e.push({type:a,place:o,value:s})}return e};n.prototype.toString=function(t){return t.map(this.getItemString,this).join("\n")};n.prototype.getItemString=function(t){var e=[t.type,t.place];var i=t.value;var n=[this.sectionId].concat(e).join("/")+"/";return"\x3c!--START %TAG%--\x3e\n%CONTENT%\n\x3c!--END %TAG%--\x3e".replace("%TAG%",n).replace("%TAG%",n).replace("%CONTENT%",i)};BX.namespace("BX.BlockEditor");BX.BlockEditor.Content=e})(window);
//# sourceMappingURL=dialog.map.js